if [ "$1" == "crypto" ]
then
    cd code/build
    make clean
    cmake ..
    make -j 128
elif [ "$1" == "openssl" ]
then
    cd code/third_party_openssl
    make clean
    ./config -d
    make -j 128
    cd ../

    cp third_party_openssl/libcrypto.a lib/
    cp third_party_openssl/libcrypto.so lib/
    cp third_party_openssl/libcrypto.so.3 lib/
    cp third_party_openssl/libssl.a lib/
    cp third_party_openssl/libssl.so lib/
    cp third_party_openssl/libssl.so.3 lib/
else
    mkdir code
    cd code

    git clone https://gitee.com/openharmony/security_certificate_framework
    git clone https://gitee.com/openharmony/security_crypto_framework.git
    git clone https://gitee.com/openharmony/third_party_googletest
    git clone https://gitee.com/openharmony/third_party_openssl
    git clone https://gitee.com/openharmony/third_party_bounds_checking_function

    cd third_party_googletest
    mkdir build
    cd build
    cmake ..
    make -j 128
    cd ../../

    cd third_party_bounds_checking_function
    make -j 128
    cd ..

    cd third_party_openssl
    echo "ossl_sm2_ciphertext_size                5560    3_0_3   EXIST::FUNCTION:" >> util/libcrypto.num
    echo "ossl_sm2_plaintext_size                 5561    3_0_3   EXIST::FUNCTION:" >> util/libcrypto.num
    echo "ossl_sm2_encrypt                        5562    3_0_3   EXIST::FUNCTION:" >> util/libcrypto.num
    echo "ossl_sm2_decrypt                        5563    3_0_3   EXIST::FUNCTION:" >> util/libcrypto.num
    ./config -d
    make -j 128
    cd ../

    mkdir lib
    cp third_party_bounds_checking_function/lib/* lib/
    cp third_party_googletest/build/lib/* lib/
    cp third_party_openssl/libcrypto.a lib/
    cp third_party_openssl/libcrypto.so lib/
    cp third_party_openssl/libcrypto.so.3 lib/
    cp third_party_openssl/libssl.a lib/
    cp third_party_openssl/libssl.so lib/
    cp third_party_openssl/libssl.so.3 lib/

    mkdir include
    cp third_party_bounds_checking_function/include/* include/
    cp -R third_party_googletest/googletest/include/* include/
    cp -R third_party_googletest/googlemock/include/* include/
    cp -R third_party_openssl/include/* include/

    cp ../CMakeLists.txt ./

    mkdir build
    cd build
    cmake ..
    make -j 128
fi